<?php
class Logger{
	public static $INFO = 1;
	public static $WARNING = 2;
	public static $ERROR = 3;
	private static $NIVEL_INFO = "INFO";
	private static $NIVEL_WARNING = "WARNING";
	private static $NIVEL_ERROR = "ERROR";

	private $logOn = true;
	public $logError = "";

	function encender(){
		$this->logOn = true;
	}

	function apagar(){
		$this->logOn = false;
	}

	function log( $mensaje, $idNivel=null){
		$this->bitacora( $mensaje, $idNivel );
		if( $this->logOn == true ){
			echo date("Y-m-d H:i:s") . " - " . $this->nivel( $idNivel ) . ": " .  $mensaje . "<br/>";
		}
	}

	function bitacora( $mensaje, $idNivel=null ){
		if( $idNivel == self::$ERROR ){
			$this->logError = $this->logError . $mensaje . " ";
		}
	}

	function nivel( $idNIVEL ){
		$nivel = null;
		switch ($idNIVEL) {
			case self::$INFO:
				$nivel = self::$NIVEL_INFO;
				break;
			case self::$WARNING:
				$nivel = self::$NIVEL_WARNING;
				break;
			case self::$ERROR:
				$nivel = self::$NIVEL_ERROR;
				break;
			default:
				$nivel = self::$NIVEL_INFO;
				break;
		}
		return $nivel;
	}
}